package com.es.controller;

import com.es.entity.MySearchRequest;
import com.es.service.GoodsService;
import com.es.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Copyright
 *
 * @Author WuHuang
 * @Date 2022/5/24
 */
@RestController
@RequestMapping("goods/")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @Autowired
    private SearchService searchService;

    @RequestMapping("save")
    public String save(){
        goodsService.save();
        return "OK";
    }

    /**
     *  查询过滤的条件
     * @param request
     * @return
     */
    @PostMapping("/filter")
    public ResponseEntity<Map<String, List<?>>> searchFilter(@RequestBody MySearchRequest request){
        return ResponseEntity.ok(searchService.searchFilter(request));
    }
}
